package xyz.xtt.exchange.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.hutool.json.JSONUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.common.response.ApiResult;
import xyz.xtt.exchange.entity.TblAssetAudit;
import xyz.xtt.exchange.service.ITblAssetAuditService;
import xyz.xtt.exchange.service.NftService;
import xyz.xtt.exchange.vo.MintRequestExRequest;

/**
 * @author dale
 * @date 2025/2/10
 **/
@Schema(name = "数藏藏会员", description = "数藏藏会员")
@Slf4j
@RestController
@RequestMapping("/api/exchange/audit")
@Validated
public class AuditController {
	@Autowired
	private ITblAssetAuditService iTblAssetAuditService;
	@Autowired
	private NftService nftService;

	@Operation(summary = "重新铸造查询")
	@GetMapping("/reMintInfo")
	public ApiResult<TblAssetAudit> info(@RequestHeader("uid") Long uid, Long id) {
		log.info("/api/exchange/audit/reMintInfo id:{}", id);
		return ApiResult.ok(iTblAssetAuditService.failInfo(uid, id));
	}

	@Operation(summary = "铸造NFT")
	@PostMapping("/v2/mint")
	public ApiResult<Long> mintEx(@RequestHeader("uid") String uid, @RequestBody @Valid MintRequestExRequest mintRequestVo) {
		log.info("/api/exchange/audit/v2/mint uid:{}, params:{}", uid, JSONUtil.toJsonStr(mintRequestVo));
		Long mint = nftService.mintEx(uid, mintRequestVo);
		return ApiResult.ok(mint);
	}
}
